package com.hjy.study.studyspringcloudpublic.util;

import java.security.MessageDigest;

/**
 * Created by hjy on 2018/6/13.
 */
public class Md5Util {
    public static String thirtyTwo(String content) {
        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
            byte[] resultByte = md.digest(content.getBytes("UTF-8"));
            StringBuffer buf = new StringBuffer("");
            int i;
            for (int offset = 0; offset < resultByte.length; offset++) {
                i = resultByte[offset];
                i = i & 0xff;
                if (i < 16)
                    buf.append("0");
                buf.append(Integer.toHexString(i));
            }
            return buf.toString();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}
